#include "utils.h"
#include <algorithm>
#include <cassert>
#include <utility>
#include <cctype>
#include <iostream>
#include <cstdint>

using namespace std;

static uint32_t
ToInt(const char *b, const char *e) {
	uint32_t ret =  0;
	for (; b != e; b++) {
		ret = ret * 10 + (*b - '0');
	}
	return ret;
}

typedef pair<string , uint32_t> P;
P ThreadCode(const char *b, const char *e) {
	assert(e - b > 2 && b[0] == '.');
	string s;
	uint32_t idx = 0;
	b += 2;
	while (b < e) {
		const char  *i = find(b, e, '/');
		if (i == e) {
			i = find(b, e, ' ');
		}
		const char *j = i - 1;
		while (isdigit(*j)) j--;
		j++;
			
		if (i == e) {
			idx = ToInt(j, i);
			break;
		}
		if (!s.empty())
			s.append(1, '-');
		s.append(j, i);
		b = i + 1;
	}
	return P(std::move(s), idx);
}
